<br><h3>评论</h3>
<div class="comment-area" id="comments">
<hr>
<form class="js-ajax-form" action="{:cmf_plugin_url('TcComment://Index/index')}" method="post">
    <input type="hidden" name="post[object_id]" id="inpId" value="{$object_id}" />
    <input type="hidden" name="post[table_name]" id="tablename" value="{$object_id}" />
    <p><textarea class="form-control comment-postbox" placeholder="我要说两句..." style="min-height:90px;" name="post[content]"></textarea></p>
	<p><button type="submit" class="btn btn-primary js-ajax-submit"><i class="fa fa-comment-o"></i> 发表评论</button></p>
</form>

<hr>
    <div class="comment-list">
    <foreach name="comments" item="vo">
	    <div class="comment" data-id="{$vo.id}" data-uid="{$vo.user_id}" data-username="{$vo.full_name}" id="comment{$vo.id}" object_id="{$vo.object_id}" path="{$vo.path}">
      <div class="common-avatar">
        <if condition="empty($vo.avatar)"><img src="/plugins/tc_comment/images/headicon.png"/><else /><img src="__ROOT__/upload/{$vo.avatar}" width="100%" height="100%"/></if>
      </div>
      <div class="comment-block">
        <p class="comment-user">{$vo.full_name}</p>
        <p class="comment-content">{$vo.content}</p>
        <div class="comment-operate">
          <span class="operate-item operate-clock">
            <i class="iconcis icon-clock"></i>
                {:date('Y-m-d H:i',$vo.create_time)}
            </span>
            <span class="operate-item operate-report">举报</span>
            <p class="float-right">
            <span class="operate-item operate-up">
                <i class="iconcis icon-zan"></i>赞
            </span>
                <span class="operate-item operate-rely">
                <i class="iconcis icon-message"></i>回复
            </span>
            </p>
        </div>
        <div class="comment-text" parent_id="{$vo.id}" style="margin-top: 10px;display: none" >
          <textarea></textarea>
          <button class="comment-btn" object_id="{$vo.object_id}" parent_id="{$vo.id}" path="{$vo.path+1}" to_user_id="{$vo.user_id}">确定</button>
        </div>
      </div>
    </div>
    </foreach>
    <ul class="pagination">
    {$page}
    </ul>
    </div>
</div>
<script src="/themes/home/public/assets/js/jquery-1.10.2.min.js"></script>
<script>
$('.operate-rely').click(function(){
  var reply = $(this).parents('.comment-block').find('.comment-text');
  if(reply.is(':hidden')){
    reply.show();
  } else {
    reply.find('textarea').val('');
    reply.hide();
  }
});
$('.comment-btn').click(function(){
  var reply_content = $(this).prev('textarea').val();
  if(reply_content==''){
    alert('请输入回复内容！');
  } else {
    var url = "/plugin/tc_comment/index/index";
    var data = {
      post:{
        object_id:$(this).attr('object_id'),
        table_name:$(this).attr('object_id'),
        content:reply_content,
        parent_id:$(this).attr('parent_id'),
        path:$(this).attr('path'),
        to_user_id:$(this).attr('to_user_id'),
      }
    };
    $.post(url,data,function(data){
      alert(data.msg);
    })
  }
});
</script>
